package com.jinboe.cms.doc.module;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Set;

import org.apache.commons.lang.StringUtils;
/**
 * 数据模块---对应DB表
 * @author weibey
 *
 */
public class DateModule {
	
	private String id;
	private String datename;
	private String table;
	private String dateAbbreviation;
	private String key;
	private List<DataEntityModule> dataEntityList=new ArrayList();
	private List<Map<String,DateModule>> outDatesList=new ArrayList();
	
	/**
	 * 加入外键数据模型
	 * @param outEntityName
	 * @param dateModule
	 */
	public void addOutDate(String outEntityName,DateModule dateModule){
		String keyName=null;
		Map map=null;
		for(Map<String,DateModule> outDatesMap:outDatesList){
			Set<String>keySet=outDatesMap.keySet();
			Iterator<String>it=keySet.iterator();
			while(it.hasNext()){
				String key=it.next();
				if(outEntityName.equalsIgnoreCase(key)){
					keyName=key;
					map=outDatesMap;
				}
			}
			
		}
		if(StringUtils.isNotBlank(keyName)){
			map.put(keyName, dateModule);
		}else{
			map=new HashMap();
			map.put(outEntityName, dateModule);
			outDatesList.add(map);
		}
	}
	public String getId() {
		return id;
	}
	public void setId(String id) {
		this.id = id;
	}
	public String getDatename() {
		return datename;
	}
	public void setDatename(String datename) {
		this.datename = datename;
	}
	public String getTable() {
		return table;
	}
	public void setTable(String table) {
		this.table = table;
	}
	public String getDateAbbreviation() {
		return dateAbbreviation;
	}
	public void setDateAbbreviation(String dateAbbreviation) {
		this.dateAbbreviation = dateAbbreviation;
	}
	public String getKey() {
		return key;
	}
	public void setKey(String key) {
		this.key = key;
	}
	public List<DataEntityModule> getDataEntityList() {
		return dataEntityList;
	}
	public void setDataEntityList(List<DataEntityModule> dataEntityList) {
		this.dataEntityList = dataEntityList;
	}
	public List<Map<String, DateModule>> getOutDatesList() {
		return outDatesList;
	}
	public void setOutDatesList(List<Map<String, DateModule>> outDatesList) {
		this.outDatesList = outDatesList;
	}
	
	
}
